Common Functions
Enter the support/common-functions/ folder and go through the practice items below.
If you get stuck, take a sneak peek at the solutions in the solution/common-functions/ folder.
Update the
putchar()function inmain_printf.cto implement a buffered functionality ofprintf(). Characters passed via theputchar()call will be stored in a predefined static global buffer. Thewrite()call will be invoked when a newline is encountered or when the buffer is full. This results in a reduced number ofwritesystem calls. Usestraceto confirm the reduction of the number ofwritesystem calls.Update the
main_printf.cfile to also feature aflush()function that forces the flushing of the static global buffer and awritesystem call. Make calls toprintf()andflush()to validate the implementation. Usestraceto inspect thewritesystem calls invoked byprintf()andflush().